#include <stdio.h>
#include <math.h>

#define PI 3.14159265

void PrintHTTPResponseHeader(void)
{
	printf("Content-Type: text/html;charset=utf-8\n\n");
}

void PrintHTMLStyles(void)
{
	printf("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/style.css\" />\n");
}

void PrintHTMLHead(void)
{
	printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n\"http://www.w3.org/TR/html4/loose.dtd\">\n");
	printf("<html>\n");
	printf("<head>\n");
	printf("<title>Sin table</title>\n");
	PrintHTMLStyles();
	printf("</head>\n");
	printf("<body>\n");
}

void PrintSinTable(void)
{
	int i, j, odd = 1;
	int degreeInterval = 10, minuteInterval = 6;
	double result = 0;

	printf("<table>\n");
	for (i = 0; i<= 360; i += degreeInterval)
	{        
		if (odd && (i > 0))
		{
			printf( "<tr class=\"odd\">\n" );
		}
		else
		{
			printf( "<tr>\n" );
		}
		odd = 1 - odd;
		if ( i == 0 )
		{
			printf( "<td></td>\n" );
		}
		else
		{
			printf( "<td class=\"name\"><strong>%d</strong></td>", i);
		}
		for (j = 0; j <= 60; j += minuteInterval)
		{
			result = sin((j / 60.0 + i) * (PI / 180.0));
			if (i == 0)
			{
				printf("<td class=\"name\"><strong>%d\'</strong></td>", j);
			}
			else
			{
				printf("<td>%f</td>", result);
			}
		}
		printf( "\n</tr>\n" );
	}
	printf("</table>\n");
}

void PrintHTMLEnd(void)
{
	printf( "</body>\n" );
	printf( "</html>\n" );
}

void main(void)
{
	PrintHTTPResponseHeader();
	PrintHTMLHead();
	PrintSinTable();
	PrintHTMLEnd();
}